package com.yqw.geotoolsguava.eventbus;

import com.google.common.eventbus.EventBus;

/**
 * 事件总线
 *
 * @Date: 2020-08-28 16:23
 * @since: 1.0
 */
public class BasicEventBus {

    //Google 提供的EventBus实现
    private EventBus basicEventBus;

    public BasicEventBus() {
        basicEventBus = new EventBus();
    }

    /**
     * 注册订阅者
     *
     * @param subscriber
     */
    public void register(Object subscriber) {
        basicEventBus.register(subscriber);
    }

    /**
     * 解除订阅关系
     *
     * @param subscriber
     */
    public void unRegister(Object subscriber) {
        basicEventBus.unregister(subscriber);
    }

    /**
     * 发布消息
     *
     * @param event
     */
    public void post(BasicEvent event) {
        basicEventBus.post(event);
    }
}
